package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 天书奇谭
 *
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(13)
public class TianshuGameStrategy extends BaseGameStrategy {
    public static final String LINK = "http://114.66.45.141:30481/gmss/user/gmquery.php";



    @GongnengMethod(1301)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type","charge");
        params.add("uid",item.uid);
        params.add("chargetype",item.itemId);
        params.add("chargenum",item.number);

        params.add("checknum","diyao88");
        params.add("qu","1");
        return RestTemplateUtil.sendPostForm(LINK, params);
    }

    @GongnengMethod(1302)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type","mail");
        params.add("uid",item.uid);
        params.add("item[]",item.itemId);
        params.add("num[]",item.number);

        params.add("title","风云精品游戏");
        params.add("content","认准风云不迷路");
        params.add("isarray","true");
        params.add("checknum","diyao88");
        params.add("qu","1");
        String s = RestTemplateUtil.sendPostForm(LINK, params);
        if(s.contains("makeMail")) return "发送成功";
        return s;
    }

    @GongnengMethod(1303)
    public String clear(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type",item.itemId);
        params.add("uid",item.uid);
        params.add("checknum","diyao88");
        params.add("qu","1");
        return RestTemplateUtil.sendPostForm(LINK, params);
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.itemId = "1";
        item.number = "22";
        item.uid = "101000001";
        String mail = new TianshuGameStrategy().mail(item);
        System.out.println(mail);
    }
}

